package com.geeker.module.sys.menu.controller;

import com.geeker.common.api.CommonResult;
import com.geeker.common.util.PageUtil;
import com.geeker.module.sys.menu.domain.SysMenu;
import com.geeker.module.sys.menu.dto.SysMenuDto;
import com.geeker.module.sys.menu.sevice.SysMenuService;
import com.mybatisflex.core.paginate.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Tag(name  = "菜单管理")
@RequestMapping("/sys/menu")
public class SysMenuController {

    @Autowired
    private SysMenuService sysMenuService;

    @Operation(summary = "分页查询")
    @PostMapping("page")
    public CommonResult<Page<SysMenu>> page(@RequestBody SysMenuDto dto) {
        Page<SysMenu> page = PageUtil.getPage(dto);
        Page<SysMenu> iPage = sysMenuService.page(page);
        return CommonResult.success(iPage);
    }

    @Operation(summary = "获取菜单列表")
    @PostMapping("list")
    public CommonResult<List<SysMenu>> menuList() {
        List<SysMenu> list = sysMenuService.menuList();
        return CommonResult.success(list);
    }
}
